#define _CRT_SECURE_NO_WARNINGS

//冒泡排序


class Solution {
public:
    vector<int> sortArray(vector<int>& nums) {
        BubbleSort(nums, nums.size());
        return nums;
    }
    void BubbleSort(vector<int>& nums, int size)
    {
        int flag = 0;
        for(int end = size - 1; end >= 0 ; end--)
        {
            for(int i = 0; i < end;  i++)
            {
                if(nums[i] > nums[i + 1])
                {
                    swap(nums[i], nums[i+1]);
                    flag = 1;
                }
            }
            if(flag == 0) break;
        }        
    }
};